package com.yoomiito.app.ui.yijiayou

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.BaseList
import com.yoomiito.app.model.oilcard.OilCardOrderDetail
import com.yoomiito.app.net.YmApi

class OilCardDetailPresenter(appConfig: AppConfig) :BaseActPresenter<OilCardDetailActivity>(appConfig){

    fun getData(page:Int){
        YmApi.getYmService()
                .oilCardDetail(page,20)
                .compose(v.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object :ApiSubscriber<BaseList<OilCardOrderDetail>>(){
                    override fun onSuccess(t: BaseList<OilCardOrderDetail>?) {
                        t?.let { v.setData(it) }
                    }

                    override fun onFail(error: ApiException?) {

                    }

                })
    }
}